<?php
include_once 'basepath.php';
if(!isset($message))
{
	$message="";
}
//print_r($lclientinbus);
//echo"---------------------------------";
//PRINT_R($lgroup);
//print_r($idtour);
//print_r($idbus);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="<?php echo $bpath;?>/css/reset.css" />
<link rel="stylesheet" href="<?php echo $bpath;?>/css/text.css" />
<link rel="stylesheet" href="<?php echo $bpath;?>/css/960_24_col.css" />
 <link rel="stylesheet" href="<?php echo $bpath;?>/css/jquery-ui-1.8.21.custom.css" />
 <link rel="stylesheet" href="<?php echo $bpath;?>/css/style.css" />
 <link rel="stylesheet" href="<?php echo $bpath;?>/css/faary.css" type="text/css" />
 <script type="text/javascript" src="<?php echo $bpath;?>/js/jquery-1.7.2.min.js"></script>
 <script type="text/javascript" src="<?php echo $bpath;?>/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="<?php echo $bpath;?>/js/scripts.js"></script>
 <script type="text/javascript" src="<?php echo $bpath;?>/js/jquery.validate.js"></script>
<script>
	$(function(){
	});
</script>
</head>

<body>
	<div class="principal container_24" style="width:1334px">
		
		<!--logo-->
		<div class="logo grid_24">
			<div class="grid_1">&nbsp;</div>
			<div class="grid_4 logoimage"><img src="<?php echo $bpath;?>/img/logo.png" height="90"></div>
			<div class="logout grid_5"><a href="index.php?loginprocess/loginout"><img src="<?php echo $bpath;?>/img/bt_logout.jpg"/></a></div>
		</div><!-- end logo-->
		
		<!--menupricipal-->
		<div class="menuprincipal grid_24" style="width:1334px">
			<a class="yearlist " href="index.php?liste/listtour">Back to List </a>
		</div>
		<!-- end menupricipal-->
				<?php if(count($linfobus)>=1 ){?>
			<div class="descprincipal grid_22">
				description
				<br/>
				<h3><?php echo $message;?></h3>
			</div>
			
				<div class="grid_24 listcontent detail">
				<h1>BUS TOUR DETAIL</h1>
				
				<div class="grid_24 top">
					<div class="topleft grid_7 " >
						<ul>
							<li>No# Bus: <span class="info">No <?php echo $linfobus[0]["code"];?></span> </li>
							<li>Tour Name: <span class="info"><?php echo $linfobus[0]["name"];?></span> </li>
							<li>Date:<span class="info"><?php echo $linfobus[0]["date"];?></span> </li>
							<li>Drive: <span class="info"><?php echo $linfobus[0]["driver"];?></span> </li>
							<li>Guide:<span class="info"><?php echo $linfobus[0]["guider"];?></span> </li>
						</ul>
					</div>
					<div class="grid_8">&nbsp;</div>
					<div class="topleft grid_8 topright" >
						<ul>
							<li>Hotel: <span class="info"><?php echo $linfobus[0]["hotel_info"];?></span> </li>
							<li>Bus Company: <span class="info"><?php echo $linfobus[0]["bus_company"];?></span> </li>
						</ul>
					</div>				
				</div>
			
					
			<div class="grid_24 detaillist datagrid" style="width:1334px">
				<?php if(count($lclientinbus)>=1  || count($lgroup)>=1){?>
				<table>
				
				<thead><tr><th>No.</th><th>NAME</th><th>PRICE<br/> FINAL</th><th>Adult</th><th>Child<th>CHAMBRE</th><th>CHMB<BR/>QTY</th><th>EMAIL</th><th>TEL</th><th>LANGUAGE</th><th>REMARK</th><th>PAID</th><th>OPTION</th></tr></thead>
				
				<tbody>
					<?php 
					if(count($lclientinbus)>=1 )
					{
					$count=1;
					$noplace=1;
					foreach ($lclientinbus as $lcb){

		// cke name from onlinename				
						
						$onlinelastname="";
						$onlinefirstname="";
						$onlineemail="";
						$flagonlinename=0;
					if($lcb["nameonline"]!="")
							{
								$onlinearr=explode("|", $lcb["nameonline"]);
								if(count($onlinearr)==3)
								{
									$onlinefirstname=$onlinearr[0];
									$onlinelastname=$onlinearr[1];
									$onlineemail=$onlinearr[2];
									$flagonlinename=1;
								}
							}
		// end cke name form onlinename		   
				?>
							
				<tr  <?php if ( $lcb["paid"]!=1){?>  class="npaid"  <?php }else{ if ($count%2==0){?>class="alt"<?php }}?>><td><?php echo $noplace; ?></td>
				<td>
				
				 <?php 
				 if($flagonlinename ==1)
				 {
				 		echo $onlinefirstname." ".$onlinelastname;
				 }else { 
				 
						 echo $lcb["firstname"]." ".$lcb["lastname"];
				 		}
				  ?>
				 
				 </td>
				<td><?php echo $lcb["salesprice"];?></td><td><?php echo $lcb["numberpeople"];?></td>
				<td><?php echo $lcb["nbchild"];?></td>
				<td>
				<?php
				switch ($lcb["chambre"]) 
				{
				case "1":
					echo "Single";
				break;
				case "2":
					echo "Double";
				break;
				case "3":
					echo "Triple";
				break;
				case "4":
					echo "Quadruple";
				break;
				}
			    ?>
				</td><td><?php echo $lcb["chambreqty"];?></td>
				<td>
				<?php	 if($flagonlinename ==1)
							 {
							 		echo $onlineemail;
							 }else 
							 { 
				 					echo $lcb["email"];
							 }	
				?>	
				</td>
				
				<td><?php echo $lcb["telphone"];?></td><td><?php echo $lcb["language"] ;?></td>
				<td class="grid_6">
				<?php echo $lcb["reminder"] ;?> 
					<form action="index.php?edit/getremider" method="post">
					<input type="hidden" name="idinscriptions" value="<?php echo  $lcb["idinscriptions"];?>"/>
					<input type="hidden" name="idtour" value="<?php echo  $idtour;?>"/>
					<input type="hidden" name="idbus" value="<?php echo  $idbus;?>"/>
					
					<input type="submit" name="Edit Rminder" value="<?php if ($lcb["reminder"]==""){?>Add<?php }else{?>Edit<?php }?>">
					</form>
				</td>
				<td><?php if( $lcb["paid"]==1) echo "Yes"; else echo "No";?>
				<?php if( $lcb["paid"]!=1){?>
				<form action="index.php?edit/actionpaid" method="post">
				<input type="hidden" name="idtour" value="<?php echo  $idtour ?>"/>
				<input type="hidden" name="idbus" value="<?php echo  $idbus ?>"/>
				<input type="hidden" name="frompage" value="listdetail"/>
				<input type="hidden" name="idinscriptions" value="<?php echo  $lcb["idinscriptions"] ?>"/>
				<input type="submit" name="paid" value="paid">
				</form>
				<?php }?>
				
				</td>
				<td>
				<?php if($level =="admin"){?>
					<form action="index.php?delete/deltrans" method="post">
					<input type="hidden" name="idinvoice" value="<?php echo  $lcb["inv_idinvoice"];?>"/>
					<input type="hidden" name="idinscriptions" value="<?php echo  $lcb["idinscriptions"];?>"/>
					<input type="hidden" name="idtour" value="<?php echo  $idtour;?>"/>
					<input type="hidden" name="idbus" value="<?php echo  $idbus;?>"/>
					<input type="submit" name="delete" value="Delete">
					</form>
					<?php }?>
					<form action="index.php?liste/viewinvoice" method="post">
						<input type="hidden" name="idclient" value="<?php echo  $lcb["idclients"];?>"/>
						<input type="hidden" name="idinvoice" value="<?php echo  $lcb["inv_idinvoice"];?>"/>
						<input type="hidden" name="idinscriptions" value="<?php echo  $lcb["idinscriptions"];?>"/>
						<input type="submit" name="edit" value="Invoice">
					</form>
				</td></tr>
				<?php 
					$count++;
					$noplace=$noplace+$lcb["numberpeople"]+$lcb["nbchild"];
					}
					}
					?>	
	<!-- group  -->				
					
				<?php 
				 if( count($lgroup)>=1){
					$count=1;
					// this variable registrer le id invocie now if id change we will change value with new id invoice
					$idinvoice=0;
					$idinvoiceeditbt=0;
					
					
					$compte=0;
					foreach ($lgroup as $lgp){
						
						$idinscription="";
						foreach ($lgp["chambre"] as $lp)
						{
						if($compte==0)
						{	
						$idinscription=$idinscription.$lp["idinscriptions"];
						}else 
						{
						
							$idinscription=$idinscription.",".$lp["idinscriptions"];
						} 
						$compte++;
						}
					
						
						$chambcount=1;
				
						foreach ($lgp["chambre"] as $lgpchambre){
							if($chambcount==1)  { 
				?>
							
				<tr  <?php  if ($lgp["person"]["paid"]!=1){?> class="npaid" <?php } else {if ($count%2==0){?>class="alt"<?php }}?>><td><?php echo $noplace; ?></td><td><?php  echo $lgp["person"]["firstname"]." ".$lgp["person"]["lastname"] ?></td><td><?php echo $lgp["person"]["salesprice"];?></td><td><?php echo $lgp["person"]["numberpeople"];?></td>
				<td>
				
				<?php
					$idinvoice=$lgpchambre["inv_idinvoice"];
					$noplace=$noplace+$lgp["person"]["numberpeople"];
				
							}
				else{
						if($idinvoice==$lgpchambre["inv_idinvoice"]){
						?>
					
						<tr  <?php if ($count%2==0){?>class="alt"<?php }?>><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
				
						<td>
					<?php }else{?>
							<tr  <?php if ($count%2==0){?>class="alt"<?php }?>><td><?php echo $noplace; ?></td><td>&nbsp;</td><td><?php echo $lgpchambre["salesprice"];?></td><td><?php echo $lgpchambre["numberpeople"];?></td>
				
						<td>
					<?php 
						$idinvoice=$lgpchambre["inv_idinvoice"];
						$noplace=$noplace+$lgp["person"]["numberpeople"];
					}?>	
				<?php 	
				}
				switch ($lgpchambre["chambre"]) 
				{
				case "1":
					echo "Single";
				break;
				case "2":
					echo "Double";
				break;
				case "3":
					echo "Triple";
				break;
				case "4":
					echo "Quadruple";
				break;
				}
			    ?>
				</td><td><?php echo $lgpchambre["chambreqty"];?></td>
			
				<?php if($chambcount==1)  { $idinvoiceeditbt=$lgpchambre["inv_idinvoice"];?>		
				<td><?php echo $lgp["person"]["email"]?></td><td><?php echo $lgp["person"]["telphone"];?></td><td><?php echo $lgp["person"]["language"] ;?></td><td><?php echo $lgp["person"]["reminder"] ;?> </td>
				<td><?php if ($lgp["person"]["paid"]==1) echo "Yes" ;else echo "No" ;?></td>
				
				<td>
				<?php if($level =="admin"){?>
					<form action="index.php?delete/deltransgroup" method="post">
						<input type="hidden" name="idinvoice" value="<?php  echo $lgpchambre["inv_idinvoice"];?>"/>
						<input type="hidden" name="idinscriptions" value="<?php echo  $idinscription ?>"/>
						<input type="hidden" name="idtours" value="<?php echo  $idtour;?>"/>
						<input type="hidden" name="idbus" value="<?php echo  $idbus; ?>"/>
						<input type="submit" name="delete" value="Delete">
					</form> 
				<?php }?>	
					<form action="index.php?liste/viewinvoicegrp" method="post">
					
						<input type="hidden" name="idclient" value="<?php echo  $lgp["person"]["fk_idclients"];?>"/>
						<input type="hidden" name="idinvoice" value="<?php  echo $lgpchambre["inv_idinvoice"];?>"/>
						
						<input type="hidden" name="idinscriptions" value="<?php echo  $idinscription ?>"/>
						<input type="submit" name="edit" value="Invoice">
						
					</form>
				</td></tr>
				<?php }else{
							if($idinvoiceeditbt!=$lgpchambre["inv_idinvoice"]){
					?>
								<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><?php echo $lgpchambre["reminder"]; ?></td><td><?php echo $lgpchambre["paid"];  ?></td><td>
								<form><input type="hidden" name="idinvoice" value="<?php echo $lgpchambre["inv_idinvoice"];?>"/><input type="submit" name="edit" value="Edit"></td></tr>
								
							<?php 
								$idinvoiceeditbt=$lgpchambre["inv_idinvoice"];
								}else{
							?>
								<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
							<?php }	?>			
				<?php 
				}
					$chambcount++;
					}
					$count++;
					}}//foreach?>	
					
					
				</tbody>
			</table></div>
			<?php }/*if $lclientinbus)>=1*/else{
			 ?>
			  	<h3>No People</h3>
			  		
			  
			<?php }	?>
		</div>
		<?php }?>
	</div><!--end principal-->
</body>
</html>